import request from '../request/reuqest'

// 通过id查询博客
export function getBlogByIdAPI (id: any) {
  return request({
    method: 'get',
    url: '/blog/getBlogById',
    params: {
      blogId: id
    }
  })
}


// 评论
export interface IgetByBlogIdcommentAPI {
  blogId: number | string;
  page: number | string;
}
export function getByBlogIdcommentAPI (data: IgetByBlogIdcommentAPI) {
  return request({
    method: 'get',
    url: '/comment/getByBlogId',
    params: data
  })
}


// 发表评论
export interface IcommentaddAPI {
  //用户昵称
  nickname: string;
  //用户id
  userId: string;
  //评论内容
  content: string;

  //用户头像
  avatar: string;
  //博客id
  blogId: number;
  //父评论id
  parentCommentId: number;
}
export function commentaddAPI (data: IcommentaddAPI) {
  return request({
    method: 'post',
    url: '/comment/my/add',
    data
  })
}

// 删除评论
export const delectcommentAPI = (commentId: number) => {
  return request({
    method: 'delete',
    url: '/comment/my/delete',
    data: {
      commentId
    }
  })
}

//按照分类，排序，页数获取博客/blog/getByTypeAndOrder
export const getByTypeAndOrderAPI = (data: any) => {
  return request({
    method: 'get',
    url: '/blog/getByTypeAndOrder',
    params: data
  })
}

// 删除博客
export const deleteArticesAPI = (data: any) => {
  return request({
    method: 'DELETE',
    url: '/blog/my/delete',
    data
  })
}

// 修改博客
export const updateArticesAPI = (data: any) => {
  return request({
    method: 'PUT',
    url: '/blog/my/update',
    data
  })
}